﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InversionOfControl;

namespace SolutionSorter.Core
{
    public class Container : IContainer
    {
        public Container()
        {
            _container = new CompactContainer();
            ConfigureContainer();
        }

        private void ConfigureContainer()
        {
            _container.DefaultLifestyle = LifestyleType.Singleton;
        }

        public void Register<TAbstract, TConcrete>() where TConcrete : TAbstract
        {
            _container.AddComponent(typeof(TAbstract), typeof(TConcrete));
        }

        public void Register<TAbstract>(TAbstract item)
        {
            _container.AddComponentInstance(typeof(TAbstract).FullName, typeof(TAbstract), item);
        }

        public T Resolve<T>()
        {
            return _container.Resolve<T>();
        }

        private readonly CompactContainer _container;
    }
}
